<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>EOS.IO: contracts/bancor/converter.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="eos-logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">EOS.IO
   &#160;<span id="projectnumber">DAWN3.0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_ae9b15dd87e066e1908bbd90e8f38627.html">contracts</a></li><li class="navelem"><a class="el" href="dir_17f794113f3d2f5e8c50affd393f94f8.html">bancor</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">converter.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="converter_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacebancor.html">bancor</a> {</div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> ConverterCurrency, <span class="keyword">typename</span> FirstCurrency, <span class="keyword">typename</span> SecondCurrency&gt;</div><div class="line"><a name="l00004"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html">    4</a></span>&#160;   <span class="keyword">class </span><a class="code" href="classbancor_1_1converter__contract.html">converter_contract</a> {</div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;      <span class="keyword">public</span>:</div><div class="line"><a name="l00006"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#ae3f4a1a3969a82defd0cdcccea700c69">    6</a></span>&#160;         <span class="keyword">typedef</span> ConverterCurrency   <a class="code" href="classbancor_1_1converter__contract.html#ae3f4a1a3969a82defd0cdcccea700c69">converter_currency</a>;</div><div class="line"><a name="l00007"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a7a46709d66c95ad9c7e4e515e959763f">    7</a></span>&#160;         <span class="keyword">typedef</span> FirstCurrency       <a class="code" href="classbancor_1_1converter__contract.html#a7a46709d66c95ad9c7e4e515e959763f">first_currency</a>;</div><div class="line"><a name="l00008"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#aca593e83f7c2c4fb7d84236979cf16fc">    8</a></span>&#160;         <span class="keyword">typedef</span> SecondCurrency      <a class="code" href="classbancor_1_1converter__contract.html#aca593e83f7c2c4fb7d84236979cf16fc">second_currency</a>;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a32e3133aa1b0937ef75191348bc966b3">   11</a></span>&#160;         <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="group__types.html#ga3b44deb4b3b8d6ebab339d1263692117">account_name</a>   <a class="code" href="classbancor_1_1converter__contract.html#a32e3133aa1b0937ef75191348bc966b3">converter_account</a> = converter_currency::code;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__state.html">   13</a></span>&#160;         <span class="keyword">struct </span><a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html">converter_state</a> {</div><div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">   14</a></span>&#160;            <span class="keyword">typename</span> converter_currency::token_type <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>; </div><div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">   15</a></span>&#160;            <span class="keyword">typename</span> converter_currency::token_type <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">balance</a>; </div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;         };</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div><div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__args.html">   18</a></span>&#160;         <span class="keyword">struct </span><a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html">converter_args</a> {</div><div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__args.html#a6d6dc6af1f019b55e958fc1113729bf3">   19</a></span>&#160;            <a class="code" href="group__types.html#ga3b44deb4b3b8d6ebab339d1263692117">eosio::account_name</a>    <a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html#a6d6dc6af1f019b55e958fc1113729bf3">to_currency_account</a>;</div><div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__args.html#a6a6d46c420ac72b22a2545a5a7e6f7e2">   20</a></span>&#160;            <a class="code" href="namespaceeosio.html#a86c678dc3ab8fd54400ddf371782d14e">eosio::symbol_name</a>     <a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html#a6a6d46c420ac72b22a2545a5a7e6f7e2">to_currency_symbol</a>;</div><div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1converter__args.html#a460bfeca8e9d060792d1ea394f2c091e">   21</a></span>&#160;            <a class="code" href="group__types.html#gaaa5d1cd013383c889537491c3cfd9aad">uint64_t</a>               <a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html#a460bfeca8e9d060792d1ea394f2c091e">min_return_currency</a>;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;         };</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;         <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CurrencyType, u<span class="keywordtype">int</span>32_t Weight=500000, u<span class="keywordtype">int</span>32_t Base=1000000&gt; </div><div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html">   26</a></span>&#160;         <span class="keyword">struct </span><a class="code" href="structbancor_1_1converter__contract_1_1connector.html">connector</a> {</div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html#a0ed25c1ccaf3a9f6d45f8960f55ec2df">   27</a></span>&#160;            <span class="keyword">typedef</span> CurrencyType                            <a class="code" href="structbancor_1_1converter__contract_1_1connector.html#a0ed25c1ccaf3a9f6d45f8960f55ec2df">currency_type</a>;</div><div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html#a69e701c71ae753f70771703badc0e9ae">   28</a></span>&#160;            <span class="keyword">typedef</span> <span class="keyword">typename</span> converter_currency::token_type <a class="code" href="structbancor_1_1converter__contract_1_1connector.html#a69e701c71ae753f70771703badc0e9ae">converter_token_type</a>;</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html#af66116d51aa7c41f03ee1abfc21cb51e">   29</a></span>&#160;            <span class="keyword">typedef</span> <span class="keyword">typename</span> currency_type::token_type      <a class="code" href="structbancor_1_1converter__contract_1_1connector.html#af66116d51aa7c41f03ee1abfc21cb51e">in_token_type</a>;</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html#a64f2755a7c9e6a66742af82ebf601421">   31</a></span>&#160;            converter_token_type <a class="code" href="structbancor_1_1converter__contract_1_1connector.html#a64f2755a7c9e6a66742af82ebf601421">convert_to_converter</a>( in_token_type in, <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html">converter_state</a>&amp; state ) {</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;               in_token_type <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">balance</a> = currency_type::get_balance( converter_account );</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;               in_token_type previous_balance = balance - in; </div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;               <span class="keyword">auto</span> init_price = (previous_balance * Base) / (Weight * state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;               <span class="keyword">auto</span> init_out   = init_price * in;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;               <span class="keyword">auto</span> out_price  = (balance*Base) / (Weight * (state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>+init_out) );</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;               <span class="keyword">auto</span> final_out  = out_price * in;</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;               state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">balance</a> += final_out;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;               state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>  += final_out;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;               <span class="keywordflow">return</span> final_out;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;            }</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="structbancor_1_1converter__contract_1_1connector.html#a33dd73e69a5ba381f7112f91ba5a047d">   50</a></span>&#160;            in_token_type <a class="code" href="structbancor_1_1converter__contract_1_1connector.html#a33dd73e69a5ba381f7112f91ba5a047d">convert_from_converter</a>( converter_token_type converter_in, <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html">converter_state</a>&amp; state ) {</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;               in_token_type  to_balance = CurrencyType::get_balance( converter_account );</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;               <span class="keyword">auto</span>          init_price = (to_balance * Base) / (Weight * state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>);</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;               in_token_type init_out   = init_price * converter_in;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;               state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>  -= converter_in;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;               state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">balance</a> -= converter_in;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;               <span class="keyword">auto</span> out_price  = ((to_balance-init_out) * Base) / ( Weight * (state.<a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">supply</a>) );</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;               <span class="keywordflow">return</span> out_price * converter_in;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;            }</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;         };</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a606723604418ba5f0432493ba2ffd818">   72</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#a606723604418ba5f0432493ba2ffd818">on_convert</a>( <span class="keyword">const</span> <span class="keyword">typename</span> converter_currency::transfer&amp; trans, </div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;                                       <span class="keyword">const</span> <a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html">converter_args</a>&amp; args, </div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;                                       <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html">converter_state</a>&amp; state ) {</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;            <span class="keywordflow">if</span>( args.to_currency_type == first_currency ) {</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;               <span class="keyword">auto</span> output = first_connector::convert_from_converter( trans.quantity, state );</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;               save_and_send( trans.from, state, output, args.min_return );</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            }</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            <span class="keywordflow">else</span> <span class="keywordflow">if</span>( args.to_currency_type == second_currency ) {</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;               <span class="keyword">auto</span> output = second_connector::convert_from_converter( trans.quantity, state );</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;               save_and_send( trans.from, state, output, args.min_return );</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;            } </div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;            <span class="keywordflow">else</span> {</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;               <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>( <span class="keyword">false</span>, <span class="stringliteral">&quot;invalid to currency&quot;</span> );</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;            }</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;         }</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;         <span class="keyword">template</span>&lt;<span class="keyword">typename</span> ConnectorType&gt;</div><div class="line"><a name="l00095"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#af868857d116887b596094fec4a4cb1e3">   95</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#af868857d116887b596094fec4a4cb1e3">on_convert</a>( <span class="keyword">const</span> <span class="keyword">typename</span> ConnectorType::currency_type::transfer&amp; trans,</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;                                       <span class="keyword">const</span> <a class="code" href="structbancor_1_1converter__contract_1_1converter__args.html">converter_args</a>&amp; args, </div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;                                       <a class="code" href="structbancor_1_1converter__contract_1_1converter__state.html">converter_state</a>&amp; state ) </div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;         {</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;            <span class="keyword">auto</span> converter_out = ConnectorType::convert_to_converter( trans.quantity, state );</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;            <span class="keywordflow">if</span>( args.to_currency_type == converter_currency )</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;            {</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;               save_and_send( trans.from, state, converter_out, args.min_return );</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;            }</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;            <span class="keywordflow">else</span> </div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;            {</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;               <span class="keyword">auto</span> output = ConnectorType::convert_from_converter( converter_out, state ); </div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;               save_and_send( trans.from, state, output, args.min_return );</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;            }</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;         }</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;         <span class="keyword">template</span>&lt;<span class="keyword">typename</span> CurrencyType&gt;</div><div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#ab04abf8e1d02393ddbc9b09b5b5a5be1">  119</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#ab04abf8e1d02393ddbc9b09b5b5a5be1">start_convert</a>( <span class="keyword">const</span> <span class="keyword">typename</span> CurrencyType::transfer_memo&amp; trans ) {</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;            <span class="keyword">auto</span> args = unpack&lt;converter_args&gt;( trans.memo );</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;            <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>( args.to_currency_type != trans.quantity.token_type(), <span class="stringliteral">&quot;cannot convert to self&quot;</span> );</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;            <span class="keyword">auto</span> state = read_converter_state();</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;            <a class="code" href="classbancor_1_1converter__contract.html#a606723604418ba5f0432493ba2ffd818">on_convert</a>( trans, args, state );</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;         }</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a9042eadac31dfc5a4133cfbecaefb66e">  136</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#a9042eadac31dfc5a4133cfbecaefb66e">on</a>( <span class="keyword">const</span> <span class="keyword">typename</span> converter_currency::transfer_memo&amp; trans ) {</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;            <a class="code" href="namespaceeosiosystem.html#a8a502c589b78b453338d6b2c5b4f405d">converter_currency::on</a>( trans );</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;            <span class="keywordflow">if</span>( trans.to == converter_account ) {</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;               <a class="code" href="classbancor_1_1converter__contract.html#ab04abf8e1d02393ddbc9b09b5b5a5be1">start_convert</a>( trans );</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;            }</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;         }</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;         <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Currency&gt;</div><div class="line"><a name="l00147"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a05d78a86731dfec1c38f8997d3392f79">  147</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#a05d78a86731dfec1c38f8997d3392f79">on</a>( <span class="keyword">const</span> <span class="keyword">typename</span> Currency::transfer_memo&amp; trans ) {</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;            <span class="keywordflow">if</span>( trans.to == converter_account ) {</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;               <a class="code" href="classbancor_1_1converter__contract.html#ab04abf8e1d02393ddbc9b09b5b5a5be1">start_convert</a>( trans );</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;            } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;               <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>( trans.from == converter_account, </div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;                       <span class="stringliteral">&quot;received unexpected notification of transfer&quot;</span> );</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;            }</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;         }</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div><div class="line"><a name="l00156"></a><span class="lineno"><a class="line" href="classbancor_1_1converter__contract.html#a77bbe12a77d7b973402f3d99273f529c">  156</a></span>&#160;         <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbancor_1_1converter__contract.html#a77bbe12a77d7b973402f3d99273f529c">apply</a>( <a class="code" href="group__types.html#ga3b44deb4b3b8d6ebab339d1263692117">account_name</a> code, <a class="code" href="group__types.html#gab0390a1836d20bbbb735af2fce1ad3e8">action_name</a> action ) {</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;            <span class="keywordflow">if</span>( !<a class="code" href="namespaceeosio.html#a78b2709044b48bb39105d37d787fefea">dispatch</a>( <a class="code" href="classbancor_1_1converter__contract.html">converter_contract</a>, </div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;                           converter_currency::transfer,</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;                           converter_currency::issue,</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;                           first_currency::transfer,</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;                           second_currency::transfer ) {</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;               <a class="code" href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a>( <span class="keyword">false</span>, <span class="stringliteral">&quot;received unexpected action&quot;</span> );</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;            }</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;         }</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;   }; </div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;} </div><div class="ttc" id="structbancor_1_1converter__contract_1_1converter__state_html_a73166e73a1a757c0955a59bd55588337"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__state.html#a73166e73a1a757c0955a59bd55588337">bancor::converter_contract::converter_state::balance</a></div><div class="ttdeci">converter_currency::token_type balance</div><div class="ttdoc">total supply held by all users </div><div class="ttdef"><b>Definition:</b> converter.hpp:15</div></div>
<div class="ttc" id="namespaceeosiosystem_html_a8a502c589b78b453338d6b2c5b4f405d"><div class="ttname"><a href="namespaceeosiosystem.html#a8a502c589b78b453338d6b2c5b4f405d">eosiosystem::on</a></div><div class="ttdeci">void on(const eosiosystem::transfer &amp;act)</div><div class="ttdef"><b>Definition:</b> eosio.system.cpp:14</div></div>
<div class="ttc" id="group__systemcapi_html_gae2a6ebaf48fe7c69f847ae18f109d09a"><div class="ttname"><a href="group__systemcapi.html#gae2a6ebaf48fe7c69f847ae18f109d09a">assert</a></div><div class="ttdeci">void assert(uint32_t test, const char *cstr)</div><div class="ttdoc">Aborts processing of this action and unwinds all pending changes. </div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html">bancor::converter_contract::connector</a></div><div class="ttdef"><b>Definition:</b> converter.hpp:26</div></div>
<div class="ttc" id="namespaceeosio_html_a78b2709044b48bb39105d37d787fefea"><div class="ttname"><a href="namespaceeosio.html#a78b2709044b48bb39105d37d787fefea">eosio::dispatch</a></div><div class="ttdeci">bool dispatch(uint64_t code, uint64_t act)</div><div class="ttdef"><b>Definition:</b> dispatcher.hpp:6</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_ab04abf8e1d02393ddbc9b09b5b5a5be1"><div class="ttname"><a href="classbancor_1_1converter__contract.html#ab04abf8e1d02393ddbc9b09b5b5a5be1">bancor::converter_contract::start_convert</a></div><div class="ttdeci">static void start_convert(const typename CurrencyType::transfer_memo &amp;trans)</div><div class="ttdef"><b>Definition:</b> converter.hpp:119</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html"><div class="ttname"><a href="classbancor_1_1converter__contract.html">bancor::converter_contract</a></div><div class="ttdef"><b>Definition:</b> converter.hpp:4</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a7a46709d66c95ad9c7e4e515e959763f"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a7a46709d66c95ad9c7e4e515e959763f">bancor::converter_contract::first_currency</a></div><div class="ttdeci">FirstCurrency first_currency</div><div class="ttdef"><b>Definition:</b> converter.hpp:7</div></div>
<div class="ttc" id="group__types_html_ga3b44deb4b3b8d6ebab339d1263692117"><div class="ttname"><a href="group__types.html#ga3b44deb4b3b8d6ebab339d1263692117">account_name</a></div><div class="ttdeci">uint64_t account_name</div><div class="ttdef"><b>Definition:</b> types.h:35</div></div>
<div class="ttc" id="group__types_html_gaaa5d1cd013383c889537491c3cfd9aad"><div class="ttname"><a href="group__types.html#gaaa5d1cd013383c889537491c3cfd9aad">uint64_t</a></div><div class="ttdeci">unsigned long long uint64_t</div><div class="ttdef"><b>Definition:</b> types.h:18</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html_a33dd73e69a5ba381f7112f91ba5a047d"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html#a33dd73e69a5ba381f7112f91ba5a047d">bancor::converter_contract::connector::convert_from_converter</a></div><div class="ttdeci">in_token_type convert_from_converter(converter_token_type converter_in, converter_state &amp;state)</div><div class="ttdef"><b>Definition:</b> converter.hpp:50</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a32e3133aa1b0937ef75191348bc966b3"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a32e3133aa1b0937ef75191348bc966b3">bancor::converter_contract::converter_account</a></div><div class="ttdeci">static const account_name converter_account</div><div class="ttdef"><b>Definition:</b> converter.hpp:11</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html_af66116d51aa7c41f03ee1abfc21cb51e"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html#af66116d51aa7c41f03ee1abfc21cb51e">bancor::converter_contract::connector::in_token_type</a></div><div class="ttdeci">currency_type::token_type in_token_type</div><div class="ttdef"><b>Definition:</b> converter.hpp:29</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_af868857d116887b596094fec4a4cb1e3"><div class="ttname"><a href="classbancor_1_1converter__contract.html#af868857d116887b596094fec4a4cb1e3">bancor::converter_contract::on_convert</a></div><div class="ttdeci">static void on_convert(const typename ConnectorType::currency_type::transfer &amp;trans, const converter_args &amp;args, converter_state &amp;state)</div><div class="ttdef"><b>Definition:</b> converter.hpp:95</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__args_html_a6a6d46c420ac72b22a2545a5a7e6f7e2"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__args.html#a6a6d46c420ac72b22a2545a5a7e6f7e2">bancor::converter_contract::converter_args::to_currency_symbol</a></div><div class="ttdeci">eosio::symbol_name to_currency_symbol</div><div class="ttdef"><b>Definition:</b> converter.hpp:20</div></div>
<div class="ttc" id="namespaceeosio_html_a86c678dc3ab8fd54400ddf371782d14e"><div class="ttname"><a href="namespaceeosio.html#a86c678dc3ab8fd54400ddf371782d14e">eosio::symbol_name</a></div><div class="ttdeci">uint64_t symbol_name</div><div class="ttdef"><b>Definition:</b> asset.hpp:24</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__args_html_a460bfeca8e9d060792d1ea394f2c091e"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__args.html#a460bfeca8e9d060792d1ea394f2c091e">bancor::converter_contract::converter_args::min_return_currency</a></div><div class="ttdeci">uint64_t min_return_currency</div><div class="ttdef"><b>Definition:</b> converter.hpp:21</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a77bbe12a77d7b973402f3d99273f529c"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a77bbe12a77d7b973402f3d99273f529c">bancor::converter_contract::apply</a></div><div class="ttdeci">static void apply(account_name code, action_name action)</div><div class="ttdef"><b>Definition:</b> converter.hpp:156</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__state_html_a3417275407c09f68e27dd3119bb82953"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__state.html#a3417275407c09f68e27dd3119bb82953">bancor::converter_contract::converter_state::supply</a></div><div class="ttdeci">converter_currency::token_type supply</div><div class="ttdef"><b>Definition:</b> converter.hpp:14</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__args_html_a6d6dc6af1f019b55e958fc1113729bf3"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__args.html#a6d6dc6af1f019b55e958fc1113729bf3">bancor::converter_contract::converter_args::to_currency_account</a></div><div class="ttdeci">eosio::account_name to_currency_account</div><div class="ttdef"><b>Definition:</b> converter.hpp:19</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a05d78a86731dfec1c38f8997d3392f79"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a05d78a86731dfec1c38f8997d3392f79">bancor::converter_contract::on</a></div><div class="ttdeci">static void on(const typename Currency::transfer_memo &amp;trans)</div><div class="ttdef"><b>Definition:</b> converter.hpp:147</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_ae3f4a1a3969a82defd0cdcccea700c69"><div class="ttname"><a href="classbancor_1_1converter__contract.html#ae3f4a1a3969a82defd0cdcccea700c69">bancor::converter_contract::converter_currency</a></div><div class="ttdeci">ConverterCurrency converter_currency</div><div class="ttdef"><b>Definition:</b> converter.hpp:6</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html_a64f2755a7c9e6a66742af82ebf601421"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html#a64f2755a7c9e6a66742af82ebf601421">bancor::converter_contract::connector::convert_to_converter</a></div><div class="ttdeci">converter_token_type convert_to_converter(in_token_type in, converter_state &amp;state)</div><div class="ttdef"><b>Definition:</b> converter.hpp:31</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a606723604418ba5f0432493ba2ffd818"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a606723604418ba5f0432493ba2ffd818">bancor::converter_contract::on_convert</a></div><div class="ttdeci">static void on_convert(const typename converter_currency::transfer &amp;trans, const converter_args &amp;args, converter_state &amp;state)</div><div class="ttdef"><b>Definition:</b> converter.hpp:72</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__args_html"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__args.html">bancor::converter_contract::converter_args</a></div><div class="ttdef"><b>Definition:</b> converter.hpp:18</div></div>
<div class="ttc" id="namespacebancor_html"><div class="ttname"><a href="namespacebancor.html">bancor</a></div><div class="ttdef"><b>Definition:</b> bancor.hpp:16</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html_a69e701c71ae753f70771703badc0e9ae"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html#a69e701c71ae753f70771703badc0e9ae">bancor::converter_contract::connector::converter_token_type</a></div><div class="ttdeci">converter_currency::token_type converter_token_type</div><div class="ttdef"><b>Definition:</b> converter.hpp:28</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1connector_html_a0ed25c1ccaf3a9f6d45f8960f55ec2df"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1connector.html#a0ed25c1ccaf3a9f6d45f8960f55ec2df">bancor::converter_contract::connector::currency_type</a></div><div class="ttdeci">CurrencyType currency_type</div><div class="ttdef"><b>Definition:</b> converter.hpp:27</div></div>
<div class="ttc" id="structbancor_1_1converter__contract_1_1converter__state_html"><div class="ttname"><a href="structbancor_1_1converter__contract_1_1converter__state.html">bancor::converter_contract::converter_state</a></div><div class="ttdef"><b>Definition:</b> converter.hpp:13</div></div>
<div class="ttc" id="group__types_html_gab0390a1836d20bbbb735af2fce1ad3e8"><div class="ttname"><a href="group__types.html#gab0390a1836d20bbbb735af2fce1ad3e8">action_name</a></div><div class="ttdeci">uint64_t action_name</div><div class="ttdef"><b>Definition:</b> types.h:41</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_aca593e83f7c2c4fb7d84236979cf16fc"><div class="ttname"><a href="classbancor_1_1converter__contract.html#aca593e83f7c2c4fb7d84236979cf16fc">bancor::converter_contract::second_currency</a></div><div class="ttdeci">SecondCurrency second_currency</div><div class="ttdef"><b>Definition:</b> converter.hpp:8</div></div>
<div class="ttc" id="classbancor_1_1converter__contract_html_a9042eadac31dfc5a4133cfbecaefb66e"><div class="ttname"><a href="classbancor_1_1converter__contract.html#a9042eadac31dfc5a4133cfbecaefb66e">bancor::converter_contract::on</a></div><div class="ttdeci">static void on(const typename converter_currency::transfer_memo &amp;trans)</div><div class="ttdef"><b>Definition:</b> converter.hpp:136</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
